const express = require('express');
const router = express.Router();
const captureCtrl = require('../controller/capture');
//显示小说列表页面
router.get('/', (req, res, next) => {
	global.navlist = 3;
	captureCtrl.getCaptureList(data => {
		res.render('list_capture', {
			list: data
		});
	});
});
router.post('/create', (req, res, next) => {
	captureCtrl.createCapture(req.body, data => {
		if(data){
			res.json({
				code:200,
				success:true,
				msg:"添加采集站点成功"
			})
		}else{
			res.json({
				code:200,
				success:false,
				msg:"添加采集站点失败"
			})
		}
	});
});
router.post('/update', (req, res, next) => {
	captureCtrl.updateCapture(req.body, data => {
		if(data){
			res.json({
				code:200,
				success:true,
				msg:"修改采集站点成功"
			})
		}else{
			res.json({
				code:200,
				success:false,
				msg:"修改采集站点失败"
			})
		}
	});
});
router.post('/delete', (req, res, next) => {
	captureCtrl.deleteCapture(req.body.id, data => {
		if(data){
			res.json({
				code:200,
				success:true,
				msg:"删除采集站点成功"
			})
		}else{
			res.json({
				code:200,
				success:false,
				msg:"删除采集站点失败"
			})
		}
	});
});
module.exports = router;